package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AtuoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);
    @AtuoFill( OperationType.INSERT )
    void insert(Dish dish);

    Page<DishVO> pageQuery(DishPageQueryDTO dto);

    Dish getById(Long id);
    @Delete( "delete from dish where id = #{id}" )
    void delete(Long id);

    void deleteByIds(List<Long> ids);

    /**
     * 修改菜品 动态SQL
     * @param dish
     */
    @AtuoFill( OperationType.UPDATE )
    void update(Dish dish);

    /**
     * 动态查询菜品
     * @param dish
     * @return
     */
    List<Dish> selectByCategoryId(Dish dish);

    /**
     * 根据套餐ID查询菜品
     * @param setmealId
     * @return
     */
    List<Dish> getBySetmealId(Long setmealId);
}
